extends TankTurret3D

@onready var smoky = $"."

@onready var smoky_shot_audio = $SmokyShotAudio
@onready var smoky_hit_audio = $SmokyHitAudio
@onready var cooldown_timer = $CooldownTimer

var is_ready_to_fire = true

func fire():
	if is_ready_to_fire:
		is_ready_to_fire = false
		cooldown_timer.start()
		smoky_shot_audio.play()
		apply_recoil()
		var target = hitscan_target()
		if target is Vector3:
			apply_explosion.rpc(target)
		elif target[0].has_method("receive_damage"):
			target[0].receive_damage.rpc_id(target[0].get_multiplayer_authority(), damage)
			target[0].apply_force_to_body.rpc_id(target[0].get_multiplayer_authority(), target[2])
			apply_explosion.rpc(target[2])

func _on_cooldown_timer_timeout():
	is_ready_to_fire = true
